package com.hotel.main.entity;

import javax.persistence.*;

import com.hotel.main.entity.enums.RoomClass;

@NamedQueries({
    @NamedQuery(name = Room.NQ_FIND_BY_PARAMETERS_CLASS_FLOOR_QUANTITY, query = "from Room r where r.roomClass=? and r.floor=? and r.roomQuantity=? and r.reserved=false"),
    @NamedQuery(name = Room.NQ_FIND_BY_PARAMETERS_CLASS_FLOOR, query = "from Room r where r.roomClass=? and r.floor=? and r.reserved=false"),
    @NamedQuery(name = Room.NQ_FIND_BY_PARAMETERS_CLASS_QUANTITY, query = "from Room r where r.roomClass=? and r.roomQuantity=? and r.reserved=false"),
    @NamedQuery(name = Room.NQ_FIND_BY_PARAMETERS_CLASS, query = "from Room r where r.roomClass=? and r.reserved=false"),
    @NamedQuery(name = Room.NQ_FIND_ALL, query = "from Room")
})
@Entity
@Table(name = "rooms")
@SequenceGenerator(name="rooms_gen", allocationSize=1, sequenceName="room_seq")
public class Room extends AbstractEntity {
	private static final long serialVersionUID = 1L;

    public static final String NQ_FIND_BY_PARAMETERS_CLASS_FLOOR_QUANTITY = "Room.NQ_FIND_BY_PARAMETERS_CLASS_FLOOR_QUANTITY";
    public static final String NQ_FIND_BY_PARAMETERS_CLASS_FLOOR = "Room.NQ_FIND_BY_PARAMETERS_CLASS_FLOOR";
    public static final String NQ_FIND_BY_PARAMETERS_CLASS_QUANTITY = "Room.NQ_FIND_BY_PARAMETERS_CLASS_QUANTITY";
    public static final String NQ_FIND_BY_PARAMETERS_CLASS = "Room.NQ_FIND_BY_PARAMETERS_CLASS";
    public static final String NQ_FIND_ALL = "Room.NQ_FIND_ALL";

	@Id 
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="rooms_gen")
	private Long id;
	
	@Column(name = "room_class")
	@Enumerated(EnumType.STRING)
	private RoomClass roomClass;
	
	@Column(name = "room_quantity")
	private Integer roomQuantity;
	
	@Column(name = "floor")
	private Byte floor;
	
	@Column(name = "reserved")
	private Boolean reserved;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@PrimaryKeyJoinColumn
	private ClientCard clientCard;

    @Override
	public void setId(Long id) {
		this.id = id;
	}

    @Override
	public Long getId() {
		return id;
	}

	public void setRoomClass(RoomClass roomClass) {
		this.roomClass = roomClass;
	}

	public RoomClass getRoomClass() {
		return roomClass;
	}

	public void setRoomQuantity(Integer roomQuantity) {
		this.roomQuantity = roomQuantity;
	}

	public Integer getRoomQuantity() {
		return roomQuantity;
	}

	public void setFloor(Byte floor) {
		this.floor = floor;
	}

	public Byte getFloor() {
		return floor;
	}

	public void setReserved(Boolean reserved) {
		this.reserved = reserved;
	}

	public Boolean isReserved() {
		return reserved;
	}

	public void setClientCard(ClientCard clientCard) {
		this.clientCard = clientCard;
	}

	public ClientCard getClientCard() {
		return clientCard;
	}
}
